﻿@using PagedList.Mvc
@model PagedList.IPagedList<Tippelde.Services.Dtos.UserWithRolesData>
@{
    ViewBag.Title = "Felhasználók";
}
<div class="row">
    <div class="col-md-12">
        <h2>Felhasználók</h2>
        <table class="table table-hover table-striped">
            <tbody>
                @foreach (var u in Model)
                {
                    <tr>
                        <td>@u.UserName</td>
                        <td>@u.FullName</td>
                        <td>@u.Email</td>
                        <td>@Html.ActionLink("Csoportok", "UserAssign", "Group", new { Id = u.UserId }, null)</td>
                        <td>
                            <div class="pull-right">
                                @using (Html.BeginForm("Delete", "User", FormMethod.Post, new { @class="form-action-delete" }))
                                {
                                    @Html.AntiForgeryToken()
                                    @Html.Hidden("userId", u.UserId)
                                    <button class='btn btn-sm btn-danger' type="submit" title="Felhasználó törlése">
                                        <span class='glyphicon glyphicon-remove'></span>
                                        Törlés
                                    </button>
                                }
                            </div>
                            <div class="pull-right">
                                @using (Html.BeginForm("ChangeRole", "User", FormMethod.Post))
                                {
                                    @Html.AntiForgeryToken()
                                    @Html.Hidden("userId", u.UserId)
                                    @Html.Hidden("roleName", "admin")
                                    @Html.Hidden("currentPage", Model.PageNumber)
                                    @Html.Hidden("isSet", !u.IsAdmin)
                                    <button class='btn btn-sm @(u.IsAdmin ? "btn-primary" : "btn-warning")' type="submit" title="Admin jogosultság @(u.IsAdmin ? "eltávolítása" : "hozzáadása")">
                                        <span class='glyphicon @(u.IsAdmin ? "glyphicon-ok" : "glyphicon-remove")'></span>
                                        Admin
                                    </button>
                                }
                            </div>
                            <div class="pull-right">
                                @using (Html.BeginForm("ChangeRole", "User", FormMethod.Post))
                                {
                                    @Html.AntiForgeryToken()
                                    @Html.Hidden("userId", u.UserId)
                                    @Html.Hidden("roleName", "teammanager")
                                    @Html.Hidden("currentPage", Model.PageNumber)
                                    @Html.Hidden("isSet", !u.IsTeamManager)
                                    <button class='btn btn-sm @(u.IsTeamManager ? "btn-primary" : "btn-warning")' type="submit" title="Csapatmenedzsment jogosultság @(u.IsTeamManager ? "eltávolítása" : "hozzáadása")">
                                        <span class='glyphicon @(u.IsTeamManager ? "glyphicon-ok" : "glyphicon-remove")'></span>
                                        Csapatmenedzsment
                                    </button>
                                }
                            </div>
                            <div class="pull-right">
                                @using (Html.BeginForm("ChangeRole", "User", FormMethod.Post))
                                {
                                    @Html.AntiForgeryToken()
                                    @Html.Hidden("userId", u.UserId)
                                    @Html.Hidden("roleName", "newsmanager")
                                    @Html.Hidden("currentPage", Model.PageNumber)
                                    @Html.Hidden("isSet", !u.IsNewsManager)
                                    <button class='btn btn-sm @(u.IsNewsManager ? "btn-primary" : "btn-warning")' type="submit" title="Hírmenedzsment jogosultság @(u.IsTeamManager ? "eltávolítása" : "hozzáadása")">
                                        <span class='glyphicon @(u.IsNewsManager ? "glyphicon-ok" : "glyphicon-remove")'></span>
                                        Hírmenedzsment
                                    </button>
                                }
                            </div>
                        </td>
                    </tr>
                }
            </tbody>
            <thead>
                <tr><th>Felhasználónév</th><th>Teljes név</th><th>Email</th><th colspan="2">Opciók</th></tr>
            </thead>
        </table>
        <div class="pull-right">
            @Html.PagedListPager(Model, page => Url.Action("Index", "User", new { Id = ViewBag.SelectedGroupId, page = page }),
    PagedListRenderOptions.OnlyShowFivePagesAtATime)
        </div>
    </div>
</div>